package babo.cd.physicalexperiment;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.RadioButton;

import com.alibaba.fastjson.JSON;
import com.github.mmin18.widget.RealtimeBlurView;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.IMqttActionListener;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttCallbackExtended;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;

import babo.cd.physicalexperiment.activity.LoginActivity;
import babo.cd.physicalexperiment.adapter.MyPagerAdapter;
import babo.cd.physicalexperiment.bean.GetMqttResultBean;
import babo.cd.physicalexperiment.bean.MaikerxuntiaojieBean;
import babo.cd.physicalexperiment.bean.ShiyanCommitZyltBean;
import babo.cd.physicalexperiment.bean.StartShiyanMqttBean;
import babo.cd.physicalexperiment.data.MyEnventData;
import babo.cd.physicalexperiment.data.UserInfo;
import babo.cd.physicalexperiment.databinding.ActivityMainBinding;
import babo.cd.physicalexperiment.fragment.HomePageFragment;
import babo.cd.physicalexperiment.fragment.MineFragment;
import babo.cd.physicalexperiment.utils.Config;
import babo.cd.physicalexperiment.utils.DeviceUuidUtils;
import babo.cd.physicalexperiment.utils.OKCallback;
import babo.cd.physicalexperiment.utils.OkUtils;
import babo.cd.physicalexperiment.utils.Out;
import babo.cd.physicalexperiment.utils.Tool;
import babo.cd.physicalexperiment.utils.URLS;


public class MainActivity extends BaseActivity {
    ActivityMainBinding binding;
    private ArrayList<Fragment> mFragments;
    private MyPagerAdapter mAdapter;
    HomePageFragment homePageFragment;
    MineFragment mineFragment;
    private String clientId = "";
    private String broker="tcp://mqtt-cn-tl327hu4508.mqtt.aliyuncs.com:1883";//连接地址
    MqttAndroidClient sampleClient;
    public void initClient() {
        try {
            DeviceUuidUtils factory = new DeviceUuidUtils(context);
            UUID deviceUuid = factory.getDeviceUuid();

            clientId = deviceUuid.toString()+System.currentTimeMillis();
            Out.out("cid=="+clientId);
            clientId="GID_master@@@"+clientId;
            Out.out("cid2=="+clientId);
            //创建客户端

            sampleClient = new MqttAndroidClient(context,broker, clientId);

            //配置回调函数
            sampleClient.setCallback(new MqttCallbackExtended() {
                @Override
                public void connectComplete(boolean reconnect, String serverUri) {
                    doSubject(Config.topic);
                }

                @Override
                public void connectionLost(Throwable cause) {
                    Out.out("connectionLostException: " + cause.getMessage());
                }

                @Override
                public void messageArrived(String topic, MqttMessage message) {

                    String body2=new String(message.getPayload());
                    Out.out("来源："+topic);

                    if (topic.startsWith(Config.topic2)){
                        Out.out("收到中点照片AA");
                        byte[]tt=message.getPayload();
                        String jg= Base64.encodeToString(tt,Base64.DEFAULT);
//                        String body=new String(message.getPayload());

                        EventBus.getDefault().post(MyEnventData.getInstance("showimg@"+jg));
                    }
                   else if (topic.startsWith(Config.topic3)){
                        Out.out("收到起点照片BBB");
                        byte[]tt=message.getPayload();
                        String jg= Base64.encodeToString(tt,Base64.DEFAULT);
                        EventBus.getDefault().post(MyEnventData.getInstance("showimgqd@"+jg));
                    }
                    else if (topic.startsWith(Config.topic4)){
                        Out.out("收到动镜图片");
                        byte[]tt=message.getPayload();
                        String jg= Base64.encodeToString(tt,Base64.DEFAULT);
                        EventBus.getDefault().post(MyEnventData.getInstance("showdongjing@"+jg));
                    }
                    else{
                        String body=new String(message.getPayload());
                        Out.out("其他数据："+body);
                        GetMqttResultBean getMqttResultBean=gson.fromJson(body,GetMqttResultBean.class);


                        try {
                            if (getMqttResultBean.getLive_state().toLowerCase().equals("start")){
                                EventBus.getDefault().post(MyEnventData.getInstance("startpull"));
                            }
                        }catch (Exception ex){}

                        Out.out("转换的数据："+gson.toJson(getMqttResultBean));
                        if (!TextUtils.isEmpty(getMqttResultBean.getIpaddr())){

                            EventBus.getDefault().post(MyEnventData.getInstance("playvedio@"));

                        }
                        try {
                            float tt=Float.parseFloat(getMqttResultBean.getTimecost());
                            if (tt>0){
                                EventBus.getDefault().post(MyEnventData.getInstance("shiyanfinish@"+getMqttResultBean.getTimecost()));

                            }
                        }catch (Exception ex){}


                        try {
                            if (getMqttResultBean.getAction().equals("adjust")){
                                String result=getMqttResultBean.getResult();
                                if (result.equals("max_alarm")){
                                    EventBus.getDefault().post(MyEnventData.getInstance("max@"));
                                }
                                if (result.equals("min_alarm")){
                                    EventBus.getDefault().post(MyEnventData.getInstance("min@"));
                                }
                            }
                        }catch (Exception ex){}

                        try {
                            if (getMqttResultBean.getAction().equals("getresult")){
                                String eror=getMqttResultBean.getError_flag().toLowerCase();
                                if (eror.equals("no_ball")){
                                    EventBus.getDefault().post(MyEnventData.getInstance("noballerror"));
                                }
                                if (eror.equals("no_timecost")){
                                    EventBus.getDefault().post(MyEnventData.getInstance("notimecose"));
                                }
                            }
                        }catch (Exception ex){}

                        try {
                            if (getMqttResultBean.getAction().equals("getresult")){
                                String eror=getMqttResultBean.getLiveType().toLowerCase();
                                if (eror.equals("local")){
                                    EventBus.getDefault().post(MyEnventData.getInstance("playlivelocal@"+getMqttResultBean.getIp()+":"+getMqttResultBean.getPort()));
                                }
                                if (eror.equals("remote")){
                                    EventBus.getDefault().post(MyEnventData.getInstance("playliveremote@"));

                                }
                            }

                        }catch (Exception exception){}

                    }

                }

                @Override
                public void deliveryComplete(IMqttDeliveryToken token) {
                    Out.out("deliveryComplete");
                }
            });
            //创建连接选择
            MqttConnectOptions connOpts = createConnectOptions("", "");
//            Out.out("Connecting to broker: " + broker);


            //创建服务连接
            sampleClient.connect(connOpts, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    //连接成功，需要上传客户端所有的订阅关系
                    Out.out("初次连接成功开始订阅AA=="+asyncActionToken.getTopics());
                    doSubject(Config.topic);
                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {

                }
            });

        } catch (MqttException | NoSuchAlgorithmException | InvalidKeyException me) {
            Out.out("initException: " + me.getMessage());
        }
    }
    private void sendMqttMessage(String msg){
        try {
            Out.out("要发送的消息："+msg);
            MqttMessage message = new MqttMessage();
            message.setPayload(msg.getBytes());
            sampleClient.publish("device_control/terminal_sub_from_app", message, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    Out.out("发送成功mqtt:"+msg);
                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    Out.out("发送失败:"+msg);

                }
            });
        } catch (MqttException e) {
            Log.e("publish", "exception", e);
        }
    }
    private void doSubject(String topic) {
        try {
            final String topicFilter[] = {topic};
            final int[] qos = {1};
            sampleClient.subscribe(topicFilter, qos, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    for (int i=0;i<asyncActionToken.getTopics().length;i++){
                        Out.out(i+"订阅成功AA=="+asyncActionToken.getTopics()[i]);
                    }


                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    Out.out("订阅成功失败："+exception);
                    exception.printStackTrace();
                    Out.out("asyncActionToken="+asyncActionToken.toString());
                }
            });

        } catch (MqttException ex) {
            Out.out("subscribe-exception=="+ex);
        }


    }

    private void doSubjectMkexImg1(String topic, String did) {
        try {
            String tt=topic+"/"+did;
            final String topicFilter[] = {tt};
            final int[] qos = {1};

            sampleClient.subscribe(topicFilter, qos, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    Out.out("订阅摄像机1成功:"+asyncActionToken.getTopics()[0]);
                    doSubjectMkexImg2(Config.topic3,did);

                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    Out.out("订阅成功失败："+exception);
                    exception.printStackTrace();
                    Out.out("asyncActionToken="+asyncActionToken.toString());
                }
            });

        } catch (MqttException ex) {
            Out.out("subscribe-exception=="+ex);
        }


    }
    private void doSubjectMkexImg2(String topic,String did) {
        try {
            String tt=topic+"/"+did;
            final String topicFilter[] = {tt};
            final int[] qos = {1};

            sampleClient.subscribe(topicFilter, qos, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    Out.out("订阅摄像机1成功:"+asyncActionToken.getTopics()[0]);
                    doSubjectMkexImg3(Config.topic4,did);

                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    Out.out("订阅成功失败："+exception);
                    exception.printStackTrace();
                    Out.out("asyncActionToken="+asyncActionToken.toString());
                }
            });

        } catch (MqttException ex) {
            Out.out("subscribe-exception=="+ex);
        }


    }
    private void doSubjectMkexImg3(String topic, String did) {
        try {
            String tt=topic+"/"+did;
            final String topicFilter[] = {tt};
            final int[] qos = {1};

            sampleClient.subscribe(topicFilter, qos, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    Out.out("订阅摄像机1成功:"+asyncActionToken.getTopics()[0]);


                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    Out.out("订阅成功失败："+exception);
                    exception.printStackTrace();
                    Out.out("asyncActionToken="+asyncActionToken.toString());
                }
            });

        } catch (MqttException ex) {
            Out.out("subscribe-exception=="+ex);
        }


    }
    private void doSubjectImg1(String topic, String did, StartShiyanMqttBean startShiyanMqttBean) {
        try {
            String tt=topic+"/"+did;
            Out.out("tt11=="+tt);
            final String topicFilter[] = {tt};
            final int[] qos = {1};
            Gson gs = new GsonBuilder().disableHtmlEscaping().create();
            Out.out("doSubjectImg1=="+ JSON.toJSONString(startShiyanMqttBean));
            sampleClient.subscribe(topicFilter, qos, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    Out.out("订阅摄像机1成功:"+asyncActionToken.getTopics()[0]);
                    doSubjectImg2(Config.topic3+"/"+did,startShiyanMqttBean);

                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    Out.out("订阅成功失败："+exception);
                    exception.printStackTrace();
                    Out.out("asyncActionToken="+asyncActionToken.toString());
                }
            });

        } catch (MqttException ex) {
            Out.out("subscribe-exception=="+ex);
        }


    }

    private void doSubjectImg2(String topic, StartShiyanMqttBean startShiyanMqttBean) {
        try {
            Gson gs = new GsonBuilder().disableHtmlEscaping().create();
            String nr=JSON.toJSONString(startShiyanMqttBean);
            Out.out("doSubjectImg2=="+nr);
            final String topicFilter[] = {topic};
            final int[] qos = {1};
            sampleClient.subscribe(topicFilter, qos, null, new IMqttActionListener() {
                @Override
                public void onSuccess(IMqttToken asyncActionToken) {
                    Out.out("订阅摄像机2成功:"+asyncActionToken.getTopics()[0]);

                    sendMqttMessage(nr);
                }

                private void doSendStart(StartShiyanMqttBean startShiyanMqttBean) {

                }

                @Override
                public void onFailure(IMqttToken asyncActionToken, Throwable exception) {
                    Out.out("订阅成功失败："+exception);
                    exception.printStackTrace();
                    Out.out("asyncActionToken="+asyncActionToken.toString());
                }
            });

        } catch (MqttException ex) {
            Out.out("subscribe-exception=="+ex);
        }


    }
    private MqttConnectOptions createConnectOptions(String userName, String passWord) throws NoSuchAlgorithmException, InvalidKeyException {
        MqttConnectOptions connOpts = new MqttConnectOptions();
        connOpts.setCleanSession(true);
        connOpts.setUserName("Signature|" + Config.accessKey + "|" + Config.instanceId);
        connOpts.setPassword(Tool.macSignature(clientId, Config.secretKey).toCharArray());


        connOpts.setAutomaticReconnect(true);
        // 设置连接超时时间, 单位为秒,默认30
        connOpts.setConnectionTimeout(30);
        // 设置会话心跳时间,单位为秒,默认20
        connOpts.setKeepAliveInterval(20);
        return connOpts;
    }
    @Override
    protected View bindView() {
        binding = ActivityMainBinding.inflate(getLayoutInflater());

        return binding.getRoot();
    }

    @Override
    protected void initView() {


        RadioButton[] rb = new RadioButton[2];
        rb[0] = binding.hometab;
        rb[1] = binding.mytab;
        for (RadioButton r : rb) {
            Drawable[] drawables = r.getCompoundDrawables();
            Rect rect = new Rect(0, 0, (int) (drawables[1].getMinimumWidth() * 1.5), (int) (drawables[1].getMinimumHeight() * 1.5));
            drawables[1].setBounds(rect);
            r.setCompoundDrawables(null, drawables[1], null, null);
        }
        mFragments = new ArrayList<>();
        homePageFragment = new HomePageFragment();
        mineFragment = new MineFragment();
        mFragments.add(homePageFragment);
        mFragments.add(mineFragment);
        List<String> datas=new ArrayList<>();
        datas.add("主页");
        datas.add("我的");

        mAdapter = new MyPagerAdapter(getSupportFragmentManager());
        mAdapter.setFragments(mFragments);
        mAdapter.setTitles(datas);
        binding.vp.setAdapter(mAdapter);

    }

    @Override
    protected void loadData() {

        initClient();
    }

    @Override
    public void setListener() {
        super.setListener();
        binding.vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                if (position==0){
                    binding.mytab.setChecked(false);
                    binding.hometab.setChecked(true);
                }else{
                    binding.mytab.setChecked(true);
                    binding.hometab.setChecked(false);
                }

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        binding.hometab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    binding.vp.setCurrentItem(0);
                }
            }
        });
        binding.mytab.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    binding.vp.setCurrentItem(1);
                }
            }
        });
    }

    public void setMssageNum(int size){
        if (size>0){
            binding.rlMsgcount.setVisibility(View.VISIBLE);
            binding.txCount.setText(size+"");
        }else{
            binding.rlMsgcount.setVisibility(View.GONE);
            binding.txCount.setText(size+"");
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onGetMessage(MyEnventData message) throws MqttException {
        String msg=message.message;
        if (msg.startsWith("yiqijiaozhun@")){
            msg=msg.replace("yiqijiaozhun@","");
            sendMqttMessage(msg);
        }
        if (msg.startsWith("mkexctwt@")){
            msg=msg.replace("mkexctwt@","");
            String [] ss=msg.split("@");
            String ctdistance=ss[0];
            String wtdistance=ss[1];
            String did=ss[2];
            MaikerxuntiaojieBean maikerxuntiaojieBean=new MaikerxuntiaojieBean();
            maikerxuntiaojieBean.setAction("adjust");
            maikerxuntiaojieBean.setDevice_id(did);
            maikerxuntiaojieBean.setDistance(ctdistance+"");
            maikerxuntiaojieBean.setExp_id("1");
            maikerxuntiaojieBean.setType("1");
            if (ctdistance.equals("0")||ctdistance.equals("0.0")||ctdistance.equals("0.00")||ctdistance.equals("0.000")||ctdistance.equals("0.0000")||ctdistance.equals("0.00000")){

            }else{
                sendMqttMessage(JSON.toJSONString(maikerxuntiaojieBean));

            }

            MaikerxuntiaojieBean maikerxuntiaojieBeanwt=new MaikerxuntiaojieBean();
            maikerxuntiaojieBeanwt.setAction("adjust");
            maikerxuntiaojieBeanwt.setDevice_id(did);
            maikerxuntiaojieBeanwt.setDistance(wtdistance+"");
            maikerxuntiaojieBeanwt.setExp_id("1");
            maikerxuntiaojieBeanwt.setType("2");

            if (wtdistance.equals("0")||wtdistance.equals("0.0")||wtdistance.equals("0.00")||wtdistance.equals("0.000")||wtdistance.equals("0.0000")||wtdistance.equals("0.00000")){

            }else{

                sendMqttMessage(JSON.toJSONString(maikerxuntiaojieBeanwt));
            }


        }
        if (msg.startsWith("dingyuetupian@")){
            msg=msg.replace("dingyuetupian@","");
            doSubjectMkexImg1(Config.topic2,msg);

        }
        if (msg.startsWith("startshiyanzylt@")){


            Out.out("msg===="+msg);

            String did=msg.replace("startshiyanzylt@","");
            String[] dds=did.split("@");
            did=dds[0];
            String purl=dds[1];
            StartShiyanMqttBean startShiyanMqttBean =new StartShiyanMqttBean();
            startShiyanMqttBean.setAction("start");
            startShiyanMqttBean.setDevice_id(did);
            startShiyanMqttBean.setExp_id("2");
            startShiyanMqttBean.setLivePushUrl(purl);

            Out.out("发送mqt==purl="+purl);
            Out.out("对象内容==purl="+startShiyanMqttBean.getLivePushUrl());


            doSubjectImg1(Config.topic2,did,startShiyanMqttBean);







        }
        if (msg.startsWith("endshiyanzylt@")){
            StartShiyanMqttBean startShiyanMqttBean =new StartShiyanMqttBean();
            String did=msg.replace("endshiyanzylt@","");
            startShiyanMqttBean.setAction("end");
            startShiyanMqttBean.setDevice_id(did);
            startShiyanMqttBean.setExp_id("2");
            sendMqttMessage(gson.toJson(startShiyanMqttBean));
            sampleClient.unsubscribe(Config.topic2+"/"+did);
            sampleClient.unsubscribe(Config.topic3+"/"+did);
        }
        if (msg.startsWith("giveupshiyanzylt@")){
            StartShiyanMqttBean startShiyanMqttBean =new StartShiyanMqttBean();
            String did=msg.replace("giveupshiyanzylt@","");
            startShiyanMqttBean.setAction("giveup");
            startShiyanMqttBean.setDevice_id(did);
            startShiyanMqttBean.setExp_id("2");
            sendMqttMessage(gson.toJson(startShiyanMqttBean));
            sampleClient.unsubscribe(Config.topic2+"/"+did);
            sampleClient.unsubscribe(Config.topic3+"/"+did);
        }
        if (msg.startsWith("giveupshiyanzyltdd@")){
            StartShiyanMqttBean startShiyanMqttBean =new StartShiyanMqttBean();
            String did=msg.replace("giveupshiyanzyltdd@","");
            startShiyanMqttBean.setAction("giveup");
            startShiyanMqttBean.setDevice_id(did);
            startShiyanMqttBean.setExp_id("2");
            sendMqttMessage(gson.toJson(startShiyanMqttBean));
            sampleClient.unsubscribe(Config.topic2+"/"+did);
            sampleClient.unsubscribe(Config.topic3+"/"+did);
            dofangqizylt(did);
        }
        if (msg.startsWith("startshiyanmkex@")){
            StartShiyanMqttBean startShiyanMqttBean =new StartShiyanMqttBean();
            String sss=msg.replace("startshiyanmkex@","");

            String[] ss=sss.split("@");
            String did=ss[0];
            String type=ss[1];
            String purl=ss[2];

            startShiyanMqttBean.setAction("start");
            startShiyanMqttBean.setDevice_id(did);
            startShiyanMqttBean.setExp_id("1");
            startShiyanMqttBean.setLivePushUrl(purl);
            startShiyanMqttBean.setLiveType(type);
            sendMqttMessage(gson.toJson(startShiyanMqttBean));


        }
        if (msg.startsWith("endshiyanmkex@")){
            StartShiyanMqttBean startShiyanMqttBean =new StartShiyanMqttBean();
            String did=msg.replace("endshiyanmkex@","");
            startShiyanMqttBean.setAction("end");
            startShiyanMqttBean.setDevice_id(did);
            startShiyanMqttBean.setExp_id("1");
            sendMqttMessage(gson.toJson(startShiyanMqttBean));
            sampleClient.unsubscribe(Config.topic2+"/"+did);
            sampleClient.unsubscribe(Config.topic3+"/"+did);
            sampleClient.unsubscribe(Config.topic4+"/"+did);

        }
        if (msg.startsWith("giveupshiyanmkex@")){
            StartShiyanMqttBean startShiyanMqttBean =new StartShiyanMqttBean();
            String did=msg.replace("giveupshiyanmkex@","");
            startShiyanMqttBean.setAction("giveup");
            startShiyanMqttBean.setDevice_id(did);
            startShiyanMqttBean.setExp_id("1");
            sendMqttMessage(gson.toJson(startShiyanMqttBean));
            sampleClient.unsubscribe(Config.topic2+"/"+did);
            sampleClient.unsubscribe(Config.topic3+"/"+did);
            sampleClient.unsubscribe(Config.topic4+"/"+did);

        }
        if (msg.startsWith("gundong@")){

            String did=msg.replace("gundong@","");

            sendMqttMessage(did);


        }
        if (msg.startsWith("begin@")){

            String did=msg.replace("begin@","");

            sendMqttMessage(did);


        }
    }

    private void dofangqizylt(String did) {
        ShiyanCommitZyltBean commitBean =new ShiyanCommitZyltBean();
        commitBean.setAppointmentId("");
        commitBean.setDeviceId(did);
        commitBean.setResult("2");
        String jsondata=gson.toJson(commitBean);
        LinkedHashMap map=new LinkedHashMap();
        map.put("data",jsondata);
        OkUtils.performByJson23(context, URLS.commitshiyan,jsondata,2,new OKCallback(context){
            @Override
            public void Sucess(String str) {
                super.Sucess(str);

            }
        });
    }
}